package com.jhws.sys.appUpgrade.api;

import com.jhws.business.aliyun.service.OSSClientService;
import com.jhws.common.base.bo.JsonRespData;
import com.jhws.sys.appUpgrade.bo.AppUpdateQR;
import com.jhws.sys.appUpgrade.service.AppUpdateQRService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@Controller
@RequestMapping("/v2/update")
public class appUpdateApiV2 extends appUpdateApi {
    @Resource
    private AppUpdateQRService appUpdateQRService;
    @Resource
    private OSSClientService ossClientService;

    @Override
    @RequestMapping({"anon/outdoor", "outdoor"})
    public void outdoorUpdate(HttpServletResponse response, String softLabel) {
        // TODO Auto-generated method stub
        super.outdoorUpdate(response, softLabel);
    }

    @Override
    @RequestMapping({"anon/mobile", "mobile"})
    public void mobileUpdate(HttpServletResponse response, String softLabel) {
        // TODO Auto-generated method stub
        super.mobileUpdate(response, softLabel);
    }

    @Override
    @RequestMapping({"anon/pad", "pad"})
    public void padUpdate(HttpServletResponse response, String softLabel) {
        // TODO Auto-generated method stub
        super.padUpdate(response, softLabel);
    }

    @RequestMapping("anon/queryAppUpdateQR")
    @ResponseBody
    public JsonRespData queryCarLaneOrder(String id) throws Exception {
        AppUpdateQR appUpdateQR = appUpdateQRService.queryAppUpdateQR(id);
        if (appUpdateQR != null) {
            appUpdateQR.setAppIocUrl(ossClientService.getUrl(appUpdateQR.getAppIoc(), false));
        }
        return new JsonRespData("", 1, appUpdateQR);
    }

}
